<?php

// mbilling/BillingBundle/Entity/ordersSharedMysqlUsers.php
namespace mbilling\BillingBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
//Порядок прав:
/*
1) Select_priv
2) Insert_priv
3) Update_priv
4) Delete_priv
5) Create_priv
6) Drop_priv
7) References_priv
8) Index_priv
9)Alter_priv
10)Create_tmp_table_priv
11)Lock_tables_priv
12)Create_view_priv
13)Show_view_priv
14)Create_routine_priv
15)Alter_routine_priv
16)Execute_priv
17)Event_priv
18)Trigger_priv
*/

/**
 * @ORM\Entity
 */
class ordersSharedMysqlUsers
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    
    /**
     * @ORM\Column(type="string", length=65, nullable="TRUE")
     */
    protected $login;

    /**
     * @ORM\Column(type="string", length=50)
     */
    protected $host;
    
    /**
     * @ORM\Column(type="string", length=40)
     */
    protected $rights;
    
    /**
     * @ORM\Column(type="integer")
     */
    protected $base_id;
    
    /**
     * @ORM\Column(type="boolean")
     */
    protected $is_active;
    
    /**
     * @ORM\Column(type="boolean")
     */
    protected $for_remove;
    
    /**
     * @ORM\Column(type="integer", nullable="TRUE")
     * @assert\Type("numeric")
     */
    protected $message_id;

    public function setId($id)
    {
        $this->id = $id;
    }
    public function getId()
    {
        return $this->id;
    }

    public function setLogin($login)
    {
        $this->login = $login;
    }
    public function getLogin()
    {
        return $this->login;
    }

    public function setHost($host)
    {
        $this->host = $host;
    }
    public function getHost()
    {
        return $this->host;
    }
    
    public function setRights($rights)
    {
        $this->rights = $rights;
    }
    public function getRights()
    {
        return $this->rights;
    }
    public function getUserRightsArray()
    {
        $rights = array();
        $temp = explode(" ", $this->rights);
        $rights['select']           = $temp['0'];
        $rights['insert']           = $temp['1'];
        $rights['update']           = $temp['2'];
        $rights['delete']           = $temp['3'];
        $rights['create']           = $temp['4'];
        $rights['drop']             = $temp['5'];
        $rights['references']       = $temp['6'];
        $rights['index']            = $temp['7'];
        $rights['alter']            = $temp['8'];
        $rights['create_tmp_table'] = $temp['9'];
        $rights['lock_tables']      = $temp['10'];
        $rights['create_view']      = $temp['11'];
        $rights['show_view']        = $temp['12'];
        $rights['create_routine']   = $temp['13'];
        $rights['alter_routine']    = $temp['14'];
        $rights['execute']          = $temp['15'];
        $rights['event']            = $temp['16'];
        $rights['trigger']          = $temp['17'];
        return $rights;
    }

    public function setBaseId($base_id)
    {
        $this->base_id = $base_id;
    }
    public function getBaseId()
    {
        return $this->base_id;
    }

    public function setIsActive($is_active)
    {
        $this->is_active = $is_active;
    }
    public function getIsActive()
    {
        return $this->is_active;
    }
    
    public function setForRemove($for_remove)
    {
        $this->for_remove = $for_remove;
    }
    public function getForRemove()
    {
        return $this->for_remove;
    }
    
    public function setMessageId($message_id)
    {
        $this->message_id = $message_id;
    }
    public function getMessageId()
    {
        return $this->message_id;
    }
    
    public function initDefaultEntity()
    {
        $this->setLogin('login');
        $this->setHost('localhost');
        $this->setRights('Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y');
        $this->setBaseId('1');
        return $this;
    }
}
?>
